package com.muyan.netty.aiosocket;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.TimeUnit;

/**
 * AIO Client 演示
 * @author zzl
 */
public class AIOClient {
    public static void main(String[] args) {
        try {
            // 打开一个SocketChannel通道并获取AsynchronousSocketChannel实例
            AsynchronousSocketChannel socketChannel = AsynchronousSocketChannel.open();
            // 连接到服务器并处理连接结果
            socketChannel.connect(new InetSocketAddress("localhost", AIOServer.AIO_PORT), null, new ClientCompletionHandler(socketChannel));
            TimeUnit.MINUTES.sleep(Integer.MAX_VALUE);
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}
